//
//  ChangeAppIconManage.swift
//  XMenSwift
//
//  Created by Jason on 2023/8/10.
//

import UIKit

enum AppIconType: Int, CaseIterable {
    
    case `default` = 1
    
    case ev = 2
    
    case other = 3
}

struct AppIconManage {
    
    static func changeAppIcon(type: AppIconType = .default) {
        //info.plist-Icon files (iOS 5)-CFBundleAlternateIcons所配置的名称
        var iconName: String? = nil
        switch type {
        case .ev:
            iconName = "Icon2"
            break
        case .other:
            iconName = "Icon3"
            break
        case .default:
            break
        }
        guard UIApplication.shared.supportsAlternateIcons else {
            return
        }
        UIApplication.shared.setAlternateIconName(iconName) { (error) in
            if error != nil {
                debugPrint("There something wrong with changing app icon!")
            }
        }
    }
}
